/**
 * Description:
 * Class Name:FilenameFilterTest
 * Date:2022/5/1 16:02
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第15章_输入输出._15_1_File类._15_1_2_文件过滤器;

import java.io.File;

public class FilenameFilterTest {
    public static void main(String[] args) {
        var file = new File(".");
        // 使用lambda表达式来实现文件过滤器，如果文件以.java结尾，或者文件对应一个路径，则返回true
        String[] nameList = file.list(((dir, name) -> name.endsWith(".java") || new File(name).isDirectory()));
        for (var name :
                nameList) {
            System.out.println(name);
        }
    }
}
//.idea
//out
//src